package com.xrit.sunnyday.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.xrit.sunnyday.dao.MemberMapper;
import com.xrit.sunnyday.pojo.Member;
import com.xrit.sunnyday.service.MemberService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.ArrayList;
import java.util.List;

@Service(interfaceClass = MemberService.class)
public class MemberServiceImpl implements MemberService {
    @Autowired
    private MemberMapper memberMapper;
    @Override
    public void add(Member member) {
        memberMapper.addMember(member);
    }

    @Override
    public Member findByTelePhone(String telephone) {
        return memberMapper.findByTelephone(telephone);
    }

    @Override
    public List<Integer> findByMonth(ArrayList<String> month) {
        //创建list集合并返回
        ArrayList<Integer> integers = new ArrayList<>();
        //遍历每个月份
        for (String m : month) {
            //每个月查一次会员数量
           Integer count= memberMapper.findByMonth(m+"-01");
           integers.add(count);
        }
        return integers;
    }
}
